﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace iLangl.Model
{
	public class Translation : DuplexObject, IHistory
	{

		private String _status;
		public String Status
		{
			get
			{
				return _status;
			}
			set
			{
				_status = value;
				updateStatus();
			}
		}

		public LanguagePair LanguagePair
		{
			get;
			set;

		}

		public int Progress
		{
			get;
			set;
		}

		public Contact Responsible { get; set; }

		public string Comment { get; set; }

		public StateHistory[] History { get; set; }

		public ContentEntity SourceContent { get; set; }
		public ContentEntity TargetContent { get; set; }

		public IProject Project
		{
			get;
			set;
		}

		public override string ToString()
		{
			return string.Format("Translation with Id=\"{0}\" ", Id);
		}

		protected virtual void updateStatus()
		{
			if (TranslationStatuses.GetStatus(this.Status) == TranslationStatuses.eTranslationStatus.Finished)
			{
				Progress = 100;
			}
		}
		
	}
}
